package cn.train.controler;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.train.model.UserTable;
import cn.train.service.UserTableService;

@WebServlet("/UpdateXinxiServlet")
public class UpdateXinxiServlet extends  HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		 String name=req.getParameter("ming");
		 String phone=req.getParameter("phone");
		 UserTable realname=(UserTable)req.getSession().getAttribute("usertable");
		 UserTable usertable = new UserTable();		 
		 usertable.setUname(name);
		 usertable.setPhonenum(phone);
		 usertable.setRealname(realname.getRealname());
		 UserTableService uts = new UserTableService();
		 boolean flag = uts.updatexinxi(usertable);
		 PrintWriter out =resp.getWriter();
		 if(flag){
//			 out.print("<script>alert('修改成功');location.href='/font/pay/vip_userinfor.jsp'</script>");
			 out.print(true);
			
		 }else {
			 out.print(false);
		 }
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}
	
}
